home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / dskutl / hdsource.arc / HDTFMT.ASM < prev    next >
Assembly Source File  |  1986-02-24  |  13KB  |  356 lines

  1.  
  2.      PAGE     64,132            ;PAGE WIDTH,LENGTH
  3.      .SALL
  4.      TITLE     PC/AT DIAGNOSTIC - FORMAT SPECIFIC HEAD
  5. ; **********************************************************************
  6. ; *                                       *
  7. ; *    MODULE NAME    HDFSEC                           *
  8. ; *    AUTHOR           JIM BRACKING                       *
  9. ; *                                       *
  10. ; *    DECSRIPTION    THIS PROGRAM PERFORMS THE FOLLOWING           *
  11. ; *               FUNCTIONS:                       *
  12. ; *                                       *
  13. ; *               1. FORMATS A SPECIFIC TRACK               *
  14. ; *                                       *
  15. ; **********************************************************************
  16. ;
  17. ; **********************************************************************
  18. ; *            EXTERNAL PROGRAM REFERENCES               *
  19. ; **********************************************************************
  20.      EXTRN     SCRMGR:NEAR,HDRW:NEAR,HDHS:NEAR
  21.      EXTRN     HDSEEK:NEAR,HDECC:NEAR
  22. ; **********************************************************************
  23. ; *              EXTERNAL DATA REFERENCES               *
  24. ; **********************************************************************
  25.      INCLUDE HDDATA.ASM
  26. ; **********************************************************************
  27. ; *            EXTERNAL SUBROUTINE REFERENCES               *
  28. ; **********************************************************************
  29.      INCLUDE HDSUB.ASM
  30.      EXTRN     LOGERR:NEAR
  31. ; **********************************************************************
  32. ; *                PUBLIC DECLARES                   *
  33. ; **********************************************************************
  34.      PUBLIC  HDTFMT
  35. ; **********************************************************************
  36. ; *                 MACROS                    *
  37. ; **********************************************************************
  38.      IF1
  39.      INCLUDE HD.MAC
  40.      INCLUDE \SCRMGR\SCRNWORK.MAC
  41.      ENDIF
  42. ; **********************************************************************
  43. ; *                                       *
  44. ; *                   BEGIN                       *
  45. ; *                                       *
  46. ; **********************************************************************
  47. CSEG     SEGMENT PARA PUBLIC 'CODE'
  48.      ASSUME CS:CSEG
  49. HDTFMT PROC    NEAR
  50.      ASSUME  DS:CSEG           ;DATA SEGMENT
  51.      JMP     BY_ID               ;JMP AROUND ID
  52.      ID     HDTFMT
  53.      INCLUDE \SCRMGR\SCRNWORK.ASM
  54. ; **********************************************************************
  55. ; *             EQUATES AND STRUCTURES                *
  56. ; **********************************************************************
  57.      INCLUDE HDEQU.ASM
  58. ; **********************************************************************
  59. ; *                 SCREENS                   *
  60. ; **********************************************************************
  61.   SFIELD X00,X01,,@LABEL,RV,23,02,'CTRL-F1 TO START'
  62.   SFIELD X01,X02,,@LABEL,RV,23,29,'ESC FOR THE MAIN MENU'
  63.   SFIELD X02,X00,,@LABEL,RV,23,62,'CTRL-BRK TO STOP'
  64. ;
  65.   SFIELD XI0,XI1,,@LABEL,LO,19,05,'DRIVE =>'
  66.   SFIELD XI1,XI2,1,@EX+@NUM+@UC+@NFULL+@REQ,LO,19,14
  67.   SFIELD XI2,XI3,,@LABEL,LO,20,05,'(1 OR 2)'
  68.   SFIELD XI3,XI4,,@LABEL,LO,19,20,'CYLINDER =>'
  69.   SFIELD XI4,XI5,4,@EX+@NUM+@NFULL+@REQ,LO,19,32
  70.   SFIELD XI5,XI6,,@LABEL,LO,20,20,'HEAD =>'
  71.   SFIELD XI6,XI9,2,@EX+@NUM+@NFULL+@REQ,LO,20,28
  72.   SFIELD XI9,XIA,,@LABEL,LO,19,46,'INTERLEAVE =>'
  73.   SFIELD XIA,XIB,1,@EX+@NUM+@NFULL+@REQ,LO,19,60
  74.   SFIELD XIB,XI0,,@LABEL,LO,20,50,'(1-8)'
  75. ;
  76.   SFIELD XS0,XS1,,@LABEL,LO,21,46,'STATUS =>'
  77.   SFIELD XS1,XS0,,@LABEL,LO,21,56,'** IDLE **   '
  78. ;
  79.   SFIELD XS2,XS3,,@LABEL,LO,21,46,'STATUS =>'
  80.   SFIELD XS3,XS2,,@LABEL,HI,21,56,'** WORKING **'
  81.   SFIELD T05,T05,,@LABEL,RV,17,33,'FORMAT TRACK'
  82. ;
  83.   SFIELD E01,E02,,@LABEL,LO,16,02,'  CYL XXXX HEAD XX HAS BEEN FORMATED'
  84.   SFIELD E02,E03,04,@LABEL,LO,16,08
  85.   SFIELD E03,E01,02,@LABEL,LO,16,18
  86. BY_ID:
  87. HDTFMT ENDP
  88. ; *********************************************************************
  89. ; *                                      *
  90. ; *            FORMAT A SPECIFIC TRACK               *
  91. ; *                                      *
  92. ; *********************************************************************
  93. FSEC     PROC
  94.      CLS     LO,4,1,23,78           ;CLEAR THE SCREEN
  95.      BOX     17,0,08,80,LO           ;OUTLINE
  96.      WRITEC  0CCH,LO,17,0,1        ;  THE
  97.      WRITEC  0B9H,LO,17,79,1       ;  SCREEN
  98.      WRITE     T05               ;TYPE OF TEST
  99.      WRITE     X00               ;COMMANDS
  100. FS_00:
  101.      LEA     BX,XIA            ;INTERLEAVE ENTRY
  102.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  103.      MOV     [BX].S_DATA,'3'       ;DEFAULT INTERLEAVE OF 3 (AT)
  104.      CMP     PCT,00H           ;IBM/AT??
  105.      JE     FS_01               ;YES
  106.      MOV     [BX].S_DATA,'6'       ;DEFAULT INTERLEAVE OF 6 (PC)
  107. FS_01:
  108.      WRITE     XS0               ;STATUS
  109.      LEA     BX,XI1            ;DRIVE ENTRY
  110.      CALL     CLR_FLD           ;CLEAR THE ENTRY
  111.      LEA     BX,XI4            ;CYLINDER
  112.      CALL     CLR_FLD           ;CLEAR THE ENTRY
  113.      LEA     BX,XI6            ;HEAD
  114.      CALL     CLR_FLD           ;CLEAR THE ENTRY
  115.      WRITE     XI0               ;MSG
  116. FS_02:
  117.      READR     BX               ;FETCH ANSWERS
  118.      CALL     TRANS_KEY           ;TRANSLATE THE KEY
  119.      JNC     FS_04               ;SUCESSFULL
  120. FS_03:
  121.      CALL     BEEP               ;RING THE BELL
  122.      JMP     FS_02               ;TRY AGAIN
  123. FS_04:
  124.      CMP     AL,ESC_KEY           ;ESCAPE KEY??
  125.      JNE     FS_05               ;NO
  126.      JMP     EXIT               ;RETURN
  127. FS_05:
  128.      CMP     AL,C_BRK           ;CONTROL BREAK KEY??
  129.      JNE     FS_07               ;NO
  130.      JMP     FSEC               ;YES - START OVER
  131. FS_07:
  132.      CMP     AL,C_F1           ;CTRL_F1??
  133.      JNE     FS_03               ;NO - INVALID KEY
  134.      LEA     BX,XI1            ;DRIVE ENTRY
  135.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  136.      MOV     AL,[BX].S_DATA        ;FETCH DRIVE NUMBER
  137.      CMP     AL,'1'                ;VALID DRIVE??
  138.      JE     FS_08               ;YES
  139.      CMP     AL,'2'                ;VALID DRIVE??
  140.      JE     FS_08               ;YES
  141.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  142.      PMSG     22               ;DISPLAY THE MESSAGE
  143.      CALL     BEEP               ;RING THE BELL
  144.      WRITE     XI0               ;DRIVE + INTERLEAVE
  145.      JMP     FS_02               ;TRY AGAIN
  146. FS_08:
  147.      AND     AL,0FH            ;ADJUST
  148.      DEC     AL               ;  DRIVE NUMBER
  149.      CMP     AL,NUM_DR           ;DRIVE INSTALLED
  150.      JB     FS_10               ;YES
  151.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  152.      PMSG     21               ;DISPLAY THE MESSAGE
  153.      CALL     BEEP               ;RING THE BELL
  154.      WRITE     XI0               ;DRIVE
  155.      JMP     FS_02               ;TRY AGAIN
  156. FS_10:
  157.      MOV     DR,AL               ;SAVE DRIVE NUMBER
  158.      LEA     BX,XI1            ;DRIVE ENTRY
  159.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  160.      WRITE     XI0               ;DRIVE
  161.      CALL     READ_PARMS           ;FETCH DRIVE PARMS
  162. ;
  163.      LEA     BX,XI4            ;CONVERT CYLINDER
  164.      CALL     CVT_HEX           ;  TO HEX IN AX
  165.      JNC     FS_20               ;SUCESSFULL
  166. FS_15:
  167.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  168.      PMSG     39               ;DISPLAY THE MESSAGE
  169.      CALL     BEEP               ;RING THE BELL
  170.      WRITE     XI0               ;DRIVE
  171.      LEA     BX,XI4            ;CYLINDER
  172.      JMP     FS_02               ;TRY AGAIN
  173. FS_20:
  174.      CMP     AX,MAX_CYL           ;IN RANGE??
  175.      JA     FS_15               ;NO
  176.      MOV     CUR_CYL,AX           ;SAVE CYLINDER
  177.      LEA     BX,XI6            ;CONVERT HEAD
  178.      CALL     CVT_HEX           ;  TO HEX IN AL
  179.      JNC     FS_30               ;SUCESSFULL
  180. FS_25:
  181.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  182.      PMSG     40               ;DISPLAY THE MESSAGE
  183.      CALL     BEEP               ;RING THE BELL
  184.      WRITE     XI0               ;DRIVE
  185.      LEA     BX,XI6            ;HEAD
  186.      JMP     FS_02               ;TRY AGAIN
  187. FS_30:
  188.      CMP     AL,MAX_HD           ;IN RANGE??
  189.      JA     FS_25               ;NO
  190.      MOV     CUR_HD,AL           ;SAVE HEAD
  191.      MOV     AL,CUR_HD           ;CONVERT HEAD
  192.      LEA     BX,XI6            ; TO
  193.      CALL     CONV_ASCII           ;   ASCII
  194.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  195.      MOV     AX,CUR_CYL           ;CONVERT CYLINDER
  196.      LEA     BX,XI4            ; TO
  197.      CALL     CONV_ASCII           ;   ASCII
  198.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  199. ; *********************************************************************
  200. ; *               PROCESS INTERLEAVE                  *
  201. ; *********************************************************************
  202.      LEA     BX,XIA            ;INTERLEAVE ENTRY
  203.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  204.      MOV     AL,[BX].S_DATA        ;FETCH INTERLEAVE
  205.      CMP     AL,'1'                ;IN RANGE??
  206.      JB     FS_45               ;NO
  207.      CMP     AL,'8'                ;IN RANGE??
  208.      JA     FS_45               ;NO
  209.      JMP     FS_50               ;CONTINUE
  210. FS_45:
  211.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  212.      PMSG     23               ;DISPLAY THE MESSAGE
  213.      CALL     BEEP               ;RING THE BELL
  214.      WRITE     XI9               ;INTERLEAVE
  215.      JMP     FS_02               ;TRY AGAIN
  216. FS_50:
  217.      XOR     AH,AH               ;CLEAR AH
  218.      AND     AL,0FH            ;MAKE IT A DIGIT
  219.      DEC     AL               ;RELEATIVE TO ZERO
  220.      XOR     DX,DX               ;CLEAR DX
  221.      MOV     CX,17               ;SECTORS PER TRACK
  222.      MUL     CX
  223.      LEA     SI,INL_TBL           ;INTERLEAVE TABLE
  224.      ADD     SI,AX               ;TABLE INDEX
  225.      XOR     AX,AX               ;PAD CHARACTER
  226.      MOV     CX,512            ;BUFFER SIZE
  227.      CLD                   ;FORWARD DIRECTION
  228.      LEA     DI,FMT_BUFF           ;FORMAT BUFFER
  229.      PUSH     DS               ;ESTABLISH
  230.      POP     ES               ;  SEGMENT
  231.      REP     STOSB               ;ZERO THE BUFFER
  232.      MOV     CX,17               ;NUMBER OF SECTORS
  233.      LEA     DI,FMT_BUFF           ;FORMAT BUFFER
  234. FS_60:
  235.      XOR     AX,AX               ;CLEAR AX
  236.      LODSB                   ;FETCH SECTOR NUMBER
  237.      XCHG     AL,AH               ;ADJUST FOR STOSW
  238.      STOSW                   ;SET SECTOR NUMBER
  239.      XOR     AX,AX               ;CLEAR AX
  240.      LOOP     FS_60               ;COMPLETE THE BUFFER
  241. FS_65:
  242.      LEA     BX,XIA            ;INTERLEAVE ENTRY
  243.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  244.      WRITE     XI0               ;REDISPLAY
  245.      CALL     HIDE_CUR           ;HIDE THE CURSOR
  246. ; *********************************************************************
  247. ; *            FORMAT THE TRACK                  *
  248. ; *********************************************************************
  249. FS_90:
  250.      PUSH     DS               ;ESTABLISH
  251.      POP     ES               ;  SEGMENT
  252.      CMP     PCT,00H           ;IBM/AT??
  253.      JNE     FS_95               ;NO
  254.      MOV     AH,FMT_CMD           ;FORMAT TRACK COMMAND
  255.      MOV     AL,17               ;NUMBER OF SECTORS
  256.      JMP     FS_100            ;CONTINUE
  257. FS_95:
  258.      MOV     AH,FMT_CMD           ;FORMAT TRACK COMMAND
  259.      LEA     BX,XIA            ;FETCH
  260.      MOV     AL,[BX].S_DATA        ;  INTERLEAVE
  261.      AND     AL,0FH            ;MAKE IT A DIGIT
  262. FS_100:
  263.      MOV     DX,CUR_CYL           ;CURRENT CYLINDER
  264.      XCHG     DH,DL               ;ADJUST IT
  265.      MOV     CX,6               ;SHIFT COUNT
  266.      SHL     DL,CL               ;ADJUST CYL HIGH
  267.      OR     DL,01H            ;SET SECTOR NUMBER
  268.      MOV     CX,DX               ;CX SET
  269.      MOV     DH,CUR_HD           ;SET HEAD
  270.      MOV     DL,DR               ;DRIVE
  271.      OR     DL,80H            ;  NUMBER
  272.      LEA     BX,FMT_BUFF           ;FORMAT BUFFER
  273.      INT     13H               ;EXECUTE THE COMMAND
  274.      MOV     AX,CUR_CYL           ;FORMAT
  275.      LEA     BX,E02            ;  CYLINDER
  276.      CALL     CONV_ASCII
  277.      XOR     AX,AX               ;CLEAR AX
  278.      MOV     AL,CUR_HD           ;FORMAT
  279.      LEA     BX,E03            ;  HEAD
  280.      CALL     CONV_ASCII
  281.      SCROLL  LO,4,2,16,78           ;SCROLL
  282.      WRITE     E01               ;DISPLAY THE MESSAGE
  283.      CALL     LOGERR            ;PRINT THE MESSAGE
  284.      LEA     BX,XI0            ;INPUT
  285.      JMP     FS_02               ;NEXT
  286. ; *********************************************************************
  287. ; *                E X I T                   *
  288. ; *********************************************************************
  289. EXIT:
  290.      RET                   ;RETURN
  291. FSEC     ENDP
  292. ; *********************************************************************
  293. ; *               CONVERT TO HEX                  *
  294. ; *********************************************************************
  295. CVT_HEX  PROC
  296.      PUSHALL
  297.      XOR     CX,CX               ;CLEAR CX
  298.      MOV     CL,[BX].S_LEN           ;FIELD LENGTH
  299.      LEA     SI,[BX].S_DATA        ;BEGINING OF FIELD
  300.      ADD     SI,CX               ;POINT TO THE
  301.      DEC     SI               ;  LAST BYTE
  302.      STD                   ;REVERSE DIRECTION
  303.      XOR     DI,DI               ;CLEAR DI
  304.      MOV     BP,1               ;STARTING MULTIPLIER
  305. CVT_00:
  306.      LODSB                   ;FETCH A BYTE
  307.      CMP     AL,' '                ;FIRST BYTE??
  308.      JNE     CVT_20            ;YES
  309.      LOOP     CVT_00            ;NEXT BYTE
  310.      JMP     CVT_ERR           ;EXIT
  311. CVT_10:
  312.      LODSB                   ;FETCH A BYTE
  313.      CMP     AL,' '                ;LAST BYTE??
  314.      JE     CVT_30            ;YES
  315. CVT_20:
  316.      CMP     AL,'.'                ;PERIOD??
  317.      JE     CVT_ERR           ;YES - ERROR
  318.      XOR     AH,AH               ;CLEAR AH
  319.      AND     AL,0FH            ;MAKE IT A DIGIT
  320.      MUL     BP               ;UP IT AGAIN
  321.      ADD     DI,AX               ;ACCUMULATE IT
  322.      MOV     AX,BP               ;RAISE THE
  323.      MOV     BP,10               ; MULTIPLIER
  324.      MUL     BP               ; BY
  325.      MOV     BP,AX               ; 10X
  326.      LOOP     CVT_10            ;NEXT BYTE
  327. CVT_30:
  328.      MOV     AX,DI               ;HEX VALUE
  329.      POPALL
  330.      CLC                   ;SUCESSFULL
  331.      RET                   ;RETURN
  332. CVT_ERR:
  333.      STC                   ;ERROR
  334.      POPALL
  335.      RET                   ;RETURN
  336. CVT_HEX  ENDP
  337. ; *********************************************************************
  338. ; *               CLEAR THE FIELD                  *
  339. ; *********************************************************************
  340. CLR_FLD  PROC
  341.      PUSHALL
  342.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  343.      CLD                   ;FORWARD DIRECTION
  344.      LEA     DI,[BX].S_DATA        ;FIELD ADDRESS
  345.      XOR     CX,CX               ;CLEAR CX
  346.      MOV     CL,[BX].S_LEN           ;FIELD LENGTH
  347.      MOV     AL,' '                ;PAD CHARACTER
  348.      PUSH     DS               ;ESTABLISH
  349.      POP     ES               ;  SEGMENT
  350.      REP     STOSB               ;CLEAR THE FIELD
  351.      POPALL
  352.      RET                   ;RETURN
  353. CLR_FLD  ENDP
  354. CSEG     ENDS
  355.      END     HDTFMT
  356.